<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<style type="text/css">
			.search_tab{ background-color: #fff; height: 50px;}
			.search_tab a{ float: left; width: 50%; text-align: center; font-size: 14px; color: #333; line-height: 50px; height: 50px; position: relative; overflow: hidden;}
			.search_tab a.on::after{ position:absolute; content: ""; left: 50%; margin-left: -10px; bottom: 0; width: 20px; border-bottom: 2px #1c63fa solid;}
			.search_tab a.on{ color: #3262F1; background-color: transparent;}
		</style>
	</head>
	<body>
		<div class="search_tab" id="header">
			<a href="javascript:;" tapmode onclick="changetab(0);"  class="on">出发地</a>
			<a href="javascript:;" tapmode onclick="changetab(1);" >目的地</a>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js" ></script>
	<script type="text/javascript" src="../../script/app.js" ></script>

	<script type="text/javascript">
		var aTabList,curIndex = 0;
		apiready = function() {
			api.parseTapmode();
			
			var keyword = api.pageParam.keyword;
			var headerH = api.pageParam.headerH;
			
			aTabList = document.getElementById("header").children;
			
			api.openFrameGroup({
				name: 'resultgroup',
				bounces: false,
				rect: {
					x: 0,
					y: headerH + 50,
					w: 'auto',
					h: 'auto'
				},
				frames: [{
					name: 'resultsend_frm',
					url: 'searchresult_frm.html',
					bgColor: '#fff',
					pageParam: {
						keyword: keyword,
						keywordtype: 'send'
					}
				}, {
					name: 'resultdest_frm',
					url: 'searchresult_frm.html',
					bgColor: '#fff',
					pageParam: {
						keyword: keyword,
						keywordtype: 'dest'
					}
				}]
			}, function(ret, err) {
				//curIndex = ret.index;
				changeIndex(ret.index);
			});
		}
		var changeIndex = function(idx){
			if (idx == curIndex) return;
			curIndex = idx;
			for (var i = 0; i < aTabList.length; i++) {
					if (i == idx) {
					$api.addCls(aTabList[idx],'on');
					} else{
					$api.removeCls(aTabList[i],'on');
					}
			}

		}
		function changetab(idx)
		{
			if (idx == curIndex) return;
			curIndex = idx;
			for (var i = 0; i < aTabList.length; i++) {
				if (i == idx) {
					$api.addCls(aTabList[idx],'on');
				} else{
					$api.removeCls(aTabList[i],'on');
				}
			}
			api.setFrameGroupIndex({
				name: 'resultgroup',
				index: idx,
				scroll: true
			});
		}
	</script>
</html>